const behav = require("../behavior");
Component({
  behaviors: [behav],
  externalClasses: ["song-item-one"],
  options: {
    styleIsolation: "apply-shared",
  },
  properties: {
    list: {
      type: Array,
      value() {
        return [];
      },
    },
  },

  data: {
    showPopup: false,
    newList: [],
  },
  observers: {
    list(newVal) {
      this.setData({
        newList: this.handleList(newVal),
      });
    },
  },
  attached() {
    this.setData({
      newList: this.handleList(this.data.list),
    });
  },
  methods: {
    handleList(list = []) {
      return list.map((item) => {
        const { ar, artists } = item;
        const ars = ar || artists || [];
        item.singers = ars.map((it) => it.name).join(" - ");
        return item;
      });
    },
    onMore(e) {
      this.setData({
        showPopup: true,
      });
    },
  },
});
